package hash表;

public class Solution242 {
    public static void main(String[] args) {
        System.out.println(isAnagram("rat", "car"));
    }

    public static boolean isAnagram(String s, String t) {
        int[] pb = new int[26];

        for (int i = 0; i < s.length(); i++) {
            pb[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            pb[t.charAt(i) - 'a']--;
        }
        for (int i = 0; i < pb.length; i++) {
            if (pb[i] != 0) {
                return false;
            }
        }
        return true;
    }
}
